<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>BOOT 客户管理系统</title>
    <link href="${ pageContext.request.contextPath }/css/bootstrap.min.css" rel="stylesheet">
    <link href="${ pageContext.request.contextPath }/css/index.css" rel="stylesheet">
    <link href="${ pageContext.request.contextPath }/css/open-iconic-bootstrap.min.css" rel="stylesheet">
    <script src="${ pageContext.request.contextPath }/js/jquery.min.js"></script>
    <script type="text/javascript">
        //页面的加载
        $(function () {
            // 发送ajax的请求
            var url = "${ pageContext.request.contextPath }/dict_findByCode.action";
            var param = {
                "dict_type_code": "006"
            };
            $.post(url, param, function (data) {
                // 遍历
                $(data).each(function (i, n) {
                    $(".levelId").append("<option value='" + n.dict_id + "'>" + n
                        .dict_item_name + "</option>");
                });
            }, "json");

            // 获取来源
            var param = {
                "dict_type_code": "002"
            };
            $.post(url, param, function (data) {
                // 遍历
                $(data).each(function (i, n) {
                    $(".sourceId").append("<option value='" + n.dict_id + "'>" + n
                        .dict_item_name + "</option>");
                });
            }, "json");
        });
    </script>
</head>

<body>
    <!-- 创建请求模态框 -->
    <div class="modal fade" id="addSingleCheckedModal" tabindex="-1" role="dialog"
        aria-labelledby="addSingleCheckedModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="addSingleCheckedModalLabel">新建客户信息</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form action="/sshBase/customer_save.action" method="post">
                        <div class="form-group row">
                            <label for="recipient-name" class="col-sm-3 col-form-label">客户名称</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="recipient-name" name="cust_name">
                            </div>

                        </div>
                        <div class="form-group row">
                            <label for="recipient-name" class="col-sm-3 col-form-label">客户来源</label>
                            <div class="col-sm-9">
                                <select class="sourceId form-control" name="source.dict_id">
                                </select></div>
                        </div>
                        <div class="form-group row">
                            <label for="recipient-name" class="col-sm-3 col-form-label">所属行业</label>
                            <div class="col-sm-9">
                                <select id="inputState" class="form-control"> 
                                </select></div>
                        </div>
                        <div class="form-group row">
                            <label for="recipient-name" class="col-sm-3 col-form-label">客户级别</label>
                            <div class="col-sm-9">
                                <select class="levelId form-control" name="level.dict_id">
                                </select></div>
                        </div>
                        <div class="form-group row">
                            <label for="recipient-name" class="col-sm-3 col-form-label">联系人</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="recipient-name" name="cust_linkman"></div>
                        </div>
                        <div class="form-group row">
                            <label for="recipient-name" class="col-sm-3 col-form-label">固定电话</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="recipient-name" name="cust_phone"></div>
                        </div>
                        <div class="form-group row">
                            <label for="recipient-name" class="col-sm-3 col-form-label">移动电话</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="recipient-name" name="cust_mobile"></div>
                        </div>
                        <div class="form-group row">
                            <label for="recipient-name" class="col-sm-3 col-form-label">邮政编码</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="recipient-name" name="custZip"></div>
                        </div>
                        <div class="form-group row">
                            <label for="recipient-name" class="col-sm-3 col-form-label">联系地址</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="recipient-name" name="custAddress"></div>
                        </div>

                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-info">提交并创建</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 模态框结束 -->

    <!-- 导航栏 -->
    <nav class="navbar navbar-dark navbar-expand bg-info text-white">
        <div class="container-fluid">
            <span class="navbar-brand mb-0 h1 nav-fix-margin">BOOT 客户管理系统</span>
            <div class="dropdown nav-fix-margin">
                <a class="btn btn-link" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    欢迎, ${ existUser.user_name }&nbsp;
                    <span class="oi oi-menu"></span>
                </a>
                <div class="dropdown-menu dropdown-menu-right">
                    <a class="dropdown-item" href="${ pageContext.request.contextPath }/user_exit.action">
                        <span class="oi oi-account-logout"></span> &nbsp;
                        退出登录
                    </a>
                </div>
            </div>
        </div>
    </nav>
    <!-- 导航栏结束 -->

    <!-- 主要内容 -->
    <div class="container-fluid">
        <div class="row">

            <!-- 页面切换和数据统计 -->

            <div class="col-md-2 fix-padding">

                <div class="card">
                    <div class="list-group " id="tabSelect">
                        <a class="list-group-item sactive text-white" id="">客户管理</a>
                        <a class="list-group-item" id="">客户拜访</a>
                    </div>
                </div>

            </div>
            <!-- 页面切换和数据统计结束 -->

            <!-- 认定审核 -->
            <div class="col-md-10 fix-padding tab-content tabs" id="firstTab">

                <div class="card">
                    <div class="card-body">
                        <h3 class="card-title">客户管理</h3>
                        <button type="button" class="btn btn-info" data-toggle="modal"
                            data-target="#addSingleCheckedModal">
                            新建
                        </button>
                    </div>
                </div>

                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">客户信息查询</h5>
                        <form action="${ pageContext.request.contextPath }/customer_findByPage.action" method=post>
                            <div class="form-row align-items-center input-group search-space">
                                <label class="my-1 mr-2 ml-2">客户名称</label>
                                <div class="col-sm-3 my-1">

                                    <input type="text" class="form-control" id="inlineFormInputName" placeholder="客户名称" name="cust_name">
                                </div>
                                <label class="my-1 mr-2 ml-2" for="exampleFormControlSelect1">客户来源</label>
                                <div class="col-sm my-1">

                                    <select class="sourceId form-control" name="source.dict_id">
                                    </select>
                                </div>
                                <label class="my-1 mr-2 ml-2" for="exampleFormControlSelect1">所属行业</label>
                                <div class="col-sm my-1">

                                    <select id="inputState" class="form-control">
                                    </select>
                                </div>
                                <label class="my-1 mr-2 ml-2" for="exampleFormControlSelect1">客户级别</label>
                                <div class="col-sm my-1">

                                    <select class="levelId form-control" name="level.dict_id">
                                    </select>
                                </div>

                                <div class="col-auto my-1">
                                    <button type="submit" class="btn btn-info">查询</button>
                                </div>
                            </div>
                        </form>


                        <table class="table">
                            <thead>
                                <tr>
                                    <th scope="col">编号</th>
                                    <th scope="col">客户名称</th>
                                    <th scope="col">客户来源</th>
                                    <th scope="col">客户所属行业</th>
                                    <th scope="col">客户级别</th>
                                    <th scope="col">固定电话</th>
                                    <th scope="col">手机</th>
                                    <th scope="col">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <c:forEach items="${page.beanList}" var="customer">
                                <tr>
                                    <td>Jacob</td>
                                    <td>${customer.cust_name }</td>
                                    <td>${customer.source.dict_item_name }</td>
                                    <td>admin</td>
                                    <td>${customer.level.dict_item_name }</td>
                                    <td>${customer.cust_phone }</td>
                                    <td>${customer.cust_mobile }</td>
                                    <td>
                                        <button type="submit" class="btn btn-sm btn-primary">修改</button>
                                        <button type="submit" class="btn btn-sm btn-danger">删除</button>
                                    </td>
                                </tr>
                                </c:forEach>
                            </tbody>
                        </table>

                        <nav aria-label="Page navigation example">
                            <ul class="pagination justify-content-center">
                                <li class="page-item disabled">
                                    <a class="page-link" href="#" tabindex="-1" aria-disabled="true">首页</a>
                                </li>
                                <li class="page-item disabled">
                                    <a class="page-link" href="#" tabindex="-1" aria-disabled="true">上一页</a>
                                </li>
                                <li class="page-item"><a class="page-link" href="#">1</a></li>
                                <li class="page-item"><a class="page-link" href="#">2</a></li>
                                <li class="page-item"><a class="page-link" href="#">3</a></li>
                                <li class="page-item">
                                    <a class="page-link" href="#">下一页</a>
                                </li>
                                <li class="page-item disabled">
                                    <a class="page-link" href="#" tabindex="-1" aria-disabled="true">尾页</a>
                                </li>
                            </ul>
                        </nav>

                    </div>
                </div>
            </div>
            <!-- 认定审核结束 -->

            <!-- 数据管理 -->
            <div class="col-md-9 fix-padding tab-content tabs" id="secondTab">

                <div class="card">
                    <div class="card-body">
                        开发中 ...
                    </div>
                </div>

            </div>
            <!-- 数据管理结束 -->

        </div>
    </div>
    <!-- 主要内容结束 -->

    <!-- 页脚 -->
    <footer class="footle bg-white">
        <div class="container">
            <span class="text-muted">&copy; 2019</span>
        </div>
    </footer>
    <!-- 页脚结束 -->

    <script src="${ pageContext.request.contextPath }/js/jquery.min.js"></script>
    <script src="${ pageContext.request.contextPath }/js/popper.min.js"></script>
    <script src="${ pageContext.request.contextPath }/js/bootstrap.min.js"></script>
    <script src="${ pageContext.request.contextPath }/js/tabs.js"></script>
</body>

</html>